import logging

from config import BASE_URL


class OpenAccountApi:

    def __init__(self, session):
        self.session = session

    # 实名认证接口
    def realname(self, realname_v, card_id_v):
        # 实现接口请求，获取响应结果
        url = BASE_URL + '/member/realname/approverealname'
        info = {"realname": realname_v, "card_id": card_id_v}
        resp = self.session.post(url, data=info, files={'k': 'y'})
        # 将响应体的数据打印到日志
        print(f'实名认证的数据为 = {resp.json()}')
        logging.info(f'实名认证的数据为 = {resp.json()}')
        # 封装方法的返回
        return resp

    # 开户接口
    def open_account(self):
        url = BASE_URL + '/trust/trust/register'
        resp = self.session.post(url)
        print(f'开户接口的数据为 = {resp.json()}')
        logging.info(f'开户接口的数据为 = {resp.json()}')
        return resp

    # 第三方开户接口
    def third_open_account(self, url, body):
        resp = self.session.post(url, data=body, files={'k': 'y'})
        print(f'第三方开户接口的数据为 = {resp.text}')
        logging.info(f'第三方开户接口的数据为 = {resp.text}')
        return resp
